// types/workbench.ts
export interface WorkbenchStats {
  pendingTransactions: number
  pendingOrders: number
  matchedCount: number
  accuracyRate: number
  efficiencyScore: number
}

export interface Transaction {
  id: string
  transactionId: string
  payerName: string
  amount: number
  transactionDate: string
  transactionTime: string
  remark?: string
  bankName?: string
  isFiltered: boolean
  dataSource: 'file_import' | 'plugin_capture'
  importBatch?: string
}

export interface SalesOrder {
  id: string
  platformOrderId: string
  customerName: string
  amount: number
  orderDate: string
  orderStatus: 'pending' | 'paid' | 'shipped' | 'completed' | 'cancelled'
  invoiceStatus: 'uninvoiced' | 'invoiced' | 'sent'
  invoiceDate?: string
  responsibleSalesman?: string
  platformSource: 'zcy' | 'manual'
}

export interface MatchResult {
  id: string
  salesOrder: SalesOrder
  bankTransaction: Transaction
  matchType: 'auto' | 'manual'
  matchAlgorithm: string
  confidence: number
  matchStatus: 'pending' | 'confirmed' | 'rejected'
  matchedBy?: string
  matchedAt: string
  confirmedBy?: string
  confirmedAt?: string
  reasoning?: {
    factors: Array<{
      factor: string
      score: number
      weight: number
      description: string
    }>
    totalScore: number
  }
}

export interface MatchSuggestion {
  type: 'quick_match' | 'batch_match' | 'algorithm_suggestion'
  confidence: number
  description: string
  action: () => void
  priority: 'high' | 'medium' | 'low'
}

export interface WorkbenchState {
  pendingTransactions: Transaction[]
  pendingOrders: SalesOrder[]
  selectedTransactions: Transaction[]
  selectedOrders: SalesOrder[]
  matchResults: MatchResult[]
  confirmedMatches: MatchResult[]
  workbenchStats: WorkbenchStats
  currentAlgorithm: string
  matchingStatus: 'idle' | 'matching' | 'success' | 'error'
  loading: boolean
}